package cn.winwintech.screenlocker

import android.app.admin.DevicePolicyManager
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters

/**
 * Background worker that executes device lock operation
 * Used for scheduled screen locking via WorkManager
 */
class LockScreenWorker(context: Context, params: WorkerParameters) : Worker(context, params) {
    
    /**
     * Performs the scheduled lock screen operation
     * @return Result.success() indicating successful execution
     */
    override fun doWork(): Result {
        val devicePolicyManager =
            applicationContext.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
        devicePolicyManager.lockNow()
        return Result.success()
    }
}